package demo2;

/**
 * @Author: XXHH
 * @CreateTime: 2025-01-12
 */
public class Computer {
    public String brand = "Huawei";
    public int age = 4;

    @Override
    public String toString() {
        return "Computer{" +
                "brand='" + brand + '\'' +
                ", age=" + age +
                '}';
    }

    public void Open(){
        System.out.println("打开电脑...");
    }
    public void Close(){
        System.out.println("关闭电脑...");
    }
    public void UseUSB(USB usb){
        usb.OpenDevice();
        // 判别
        if (usb instanceof Keyboard){
//            Keyboard keyboard = new Keyboard();
//            keyboard.Input();
            ((Keyboard)usb).Input();
        }else if (usb instanceof Mouse){
            ((Mouse) usb).click();
        }
        usb.CloseDevice();
    }
}
